import request from '@/utils/request';
import { PageResponse } from '@/interface/pages';

/**
 * 获取分页列表
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getGoodsSpecsList = (params: API.goodsSpecs.PageListDto) => {
  return request<PageResponse<API.goodsSpecs.EntitySchema[]>>({
    url: '/admin/specs',
    method: 'get',
    params
  });
};

/**
 * 创建
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const createGoodsSpecs = (data: API.goodsSpecs.EntityDto) => {
  return request({
    url: `/admin/specs`,
    method: 'post',
    data
  });
};

/**
 * 修改
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const updateGoodsSpecs = (
  id: number,
  data: API.goodsSpecs.EntityDto
) => {
  return request({
    url: `/admin/specs/${id}`,
    method: 'put',
    data
  });
};

/**
 * 删除
 *
 * @param id
 * @returns
 *
 * @todo 发起axios请求
 */
export const deleteGoodsSpecs = (id: number): Promise<any> => {
  return request({
    url: `/admin/specs/${id}`,
    method: 'delete'
  });
};
